<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" type="text/css" href="../../css/global/public.css" />
<link rel="stylesheet" type="text/css" href="../../css/global/mui.css">
<link rel="stylesheet" type="text/css" href="../../css/prescription-wechat.css"/>
<title>处方单</title>
</head>
<body>
	<div class="font3 textC arrivalInvite">目前到店自取功能只支持武汉地区</div>
	<div class="prescription-wechatBox">
		<div class="title font3">
			我的处方单
		</div>
		<div class="main">
			<div class="prompt font3">
				扫码可查看我的处方单
			</div>
			<div class="barCode">
				<img class="bind_qrCode" alt="">
			</div>
			<div class="number font1">
				<span>验证码<font class="bind_code font1">6200 0103 0215 09</font></span>
			</div>
			<!--<div class="code">
				<div class="QRcode"><img class="bind_qrCode" alt=""></div>
				<p>扫一扫取码</p>
				<i style="left:-0.15rem;"></i>
				<i style="right:-0.15rem;"></i>
			</div>-->
		</div>
	</div>
	<div class="prescription-wechatOrder font3">
		<!--<p class="number">馨语订单号<span class="bind_ordersn">11268450</span></p>-->
		<p class="total-price font3">温馨提示<!--<span class="bind_prescriptionPrice">¥20</span>--></p>
		<div class="friendlyreminder font1"><span class="xing">*</span><p class="reminder">武汉市新洲区慢病患者仅可取得新洲精神病医院发票方可进行慢病报销.</p></div>
	</div>
	<div class="prescription-wechatAdress">
		<label class="bind_name font3">硚口店</label><span class="bind_distance"> <1.6km</span>
		<p class="bind_address font1">长水路樱花街商行银座605号</p>
		<a id="bind_url"></a>
	</div>
	<div class="prescription-wechatNow font3">
		<div>使用需知</div>
	</div>
</body>
</html>
<script type="text/javascript" src="../../js/lib/mui.min.js" ></script>
<script type="text/javascript" src="../../js/module/utilModule.js" ></script> 
<script type="text/javascript" src="../../js/common/config.js"></script>
<script type="text/javascript" src="../../js/lib/zepto.min.js" ></script>
<script type="text/javascript" src="../../js/common/common.js"></script>
<script type="text/javascript" src="../../js/module/userCenterModule.js" ></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

<!-- <script type="text/javascript" src="../../js/userCenter/userCenter.js" ></script> -->
<script>
$(function() {
    //获取 orderid 
	var orderid = utilModule.getQueryString("orderid")?utilModule.getQueryString("orderid"):1;
    utilModule.get({
        url: "userCenter/getOnePrescription",
        data: {"id":orderid},
        needJson: false, 
        async: false,
        success: function (response) {
        	$(".bind_code").html(response.prescriptionCode);
        	$(".bind_qrCode").attr('src',response.barcodePath);
        	$(".bind_ordersn").html(response.ordersn);
        	$(".bind_prescriptionPrice").html(response.prescriptionPrice);
    	
    		var totalPrice=0;
        	for(var i=0;i<response.prescriptionDetailList.length;i++){
        		  var item=response.prescriptionDetailList[i];
        		  console.log(item);
        		  totalPrice+=item.price*item.count;
        		}
        		totalPrice = totalPrice.toFixed(2); 
			$(".bind_prescriptionPrice").html("¥"+totalPrice);
        	}   
        
    });
     $(".prescription-wechatNow div").on("click",function(){
    	location.href = "../userCenter/user-know.html"
    });
   
    //获取ApiSign
	function initGetJsApiSign(url) {
		var params = {
			"url" : url
		};
		userCenterModule.getJsApiSign(params, function(callback) {
			var info = callback;
			if (info != null) {
				wx.config({
					debug : false,  /*正常模式*/   // true开启调试模式 //  
					appId : info.appId,
					timestamp : info.timestamp, // 必填，生成签名的时间戳
					nonceStr : info.nonceStr, // 必填，生成签名的随机串
					signature : info.signature, // 必填，签名，见附录1
					jsApiList : [ 'scanQRCode', 'getLocation']
				});
			}
		});
	}
       
	initGetJsApiSign("n/html/prescription/prescription-wechat.html?orderid="+orderid);
	 
	 
	wx.ready(function(){ 
	   wx.getLocation({
	    	success: function(res) {
	    		console.log("###############"+res);
		        var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
		        var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
		        //去数据库查询获取附近的门店
	            utilModule.get({
	                url: "prescription/getBestPharmacy",
	                data: {"latitude":latitude,"longitude":longitude},
	                needJson: false, 
	                async: false,
	                success: function (response) { 
	                		response = response[0]
	                    	var url = "http://apis.map.qq.com/tools/poimarker?type=0&marker=coord:"+response.lat+","+response.lon+";title:"+response.name+";addr:"+response.address+"&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&referer=myappr=myapp"	
	                    	$(".prescription-wechatAdress").on('click',function(){
	                    		location.href = url;
	                    	});
	                    	$(".bind_address").html(response.address);
	                    	$(".bind_name").html(response.name);
	                    	$(".bind_distance").html(response.juli+"m");

	                }
	            });
			}
		});
		wx.error(function(res) {
			mui.alert("返回结果：" + res.errMsg);
		});
	});		
});
</script>